import { defineStore } from "pinia";
export interface useAllStoreType {
  tagsList: {
    path: string;
    name: string;
    title: string;
    index: number;
  }[];
  user: { username: string; avatar: string };
  collapse: boolean;
  token: string;
  menu: routeType[];
  account: accountType | {};
}
export interface routeType {
  path: string;
  name: string;
  component?: string | (() => Promise<unknown>);
  redirect?: string;
  meta: {
    title: string;
    icons?: string;
    img?: string;
  };
  children?: routeType[];
}
type accountType = {
  username: string;
  password: string;
};
export const useAllStore = defineStore("allstore", {
  state: (): useAllStoreType => ({
    user: { username: "", avatar: "" },
    collapse: false,
    token: "",
    menu: [],
    account: { username: "", password: "" },
    tagsList: []
  }),
  actions: {
    handleCollapse(e: boolean) {
      this.collapse = e;
    }
  },
  persist: [
    { paths: ["token", "user", "menu", "account"], storage: localStorage },
    { paths: ["collapse"], storage: sessionStorage }
  ]
});
